package com.gxkj.movie.threads;

import com.alibaba.fastjson.JSON;
import com.gxkj.movie.config.utils.SpringContextUtil;
import com.gxkj.movie.dtos.ReqLog;
import com.gxkj.movie.helpers.BaiduSpiderHelper;
import com.gxkj.movie.helpers.LogWebsiteVisitHelper;
import lombok.extern.slf4j.Slf4j;
import org.git.movie.entity.LogWebsiteVisit;

/**
 * @author sqyc
 */
@Slf4j
public class ReqLogSubmiThread implements Runnable{

    ReqLog reqLog;

    public ReqLogSubmiThread(ReqLog reqLog) {

        this.reqLog = reqLog;
    }

    @Override
    public void run() {


      //  log.info( "打印log参数："+JSON.toJSONString(reqLog));

        LogWebsiteVisitHelper logWebsiteVisitHelper =  SpringContextUtil.getBean(LogWebsiteVisitHelper.class);

        LogWebsiteVisit logWebsiteVisit = new LogWebsiteVisit();
        logWebsiteVisit.setAccept(reqLog.getAccept());
        logWebsiteVisit.setAppname(reqLog.getAppName());
        logWebsiteVisit.setClientDevice1Id(reqLog.getDeviceId1());
        logWebsiteVisit.setClientDevice1Type(reqLog.getDeviceId1from());
        logWebsiteVisit.setReferer(reqLog.getReferer());
        logWebsiteVisit.setUserid(reqLog.getUserId());
        logWebsiteVisit.setUsertype(reqLog.getUserType());
        logWebsiteVisit.setClientIp(reqLog.getCustomerIp());

        logWebsiteVisit.setCreateAt(reqLog.getTimestamp());
        logWebsiteVisit.setMethod(reqLog.getMethod());
        logWebsiteVisit.setTraceid(reqLog.getTraceId());
        logWebsiteVisit.setServerIp(reqLog.getServerIp());
        logWebsiteVisit.setUri(reqLog.getURL());

        logWebsiteVisit.setTaketime(reqLog.getTakeTime());

        logWebsiteVisitHelper.doInsert(logWebsiteVisit);
    }
}
